﻿<Fluent:RibbonWindow x:Class="NavigationPaneDemo.MainWindow"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                     xmlns:demo="clr-namespace:NavigationPaneDemo"
                     xmlns:Fluent="clr-namespace:Fluent;assembly=Fluent"
                     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                     xmlns:s="NavigationPane"
                     Title="Navigation Pane v1.0"
                     Background="{Binding Background,
                                          ElementName=navigationPaneExpander}"
                     Icon="Resources/folderopen.ico"
                     Loaded="RibbonWindow_Loaded"
                     ResizeMode="CanResizeWithGrip"
                     WindowStartupLocation="CenterScreen"
                     mc:Ignorable="d">

    <Fluent:RibbonWindow.Resources>
        <!--
            THEMES
            
            The theme can be canged in two ways
            By statically merging the theme Dictionary resource in the app.xaml o by code behind
            - to see the exact dictionary path for each theme and have futher informations, see ths application app.xaml file
            - to see how to change the theme in code behind see the implementation in the "Themes" item
        -->
        <ResourceDictionary>
            <s:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter1" />
            <s:BooleanNegateConverter x:Key="BooleanNegateConverter" />
            <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        </ResourceDictionary>
    </Fluent:RibbonWindow.Resources>

    <DockPanel DataContext="{Binding Source={StaticResource SampleDataSource1}}">
        <Fluent:Ribbon DockPanel.Dock="Top">
            <Fluent:Ribbon.Menu>
                <Fluent:Backstage Background="#FF7777A1" />
            </Fluent:Ribbon.Menu>
            <Fluent:RibbonTabItem Header="View">
                <Fluent:RibbonGroupBox Header="Layout">
                    <Fluent:DropDownButton Header="Navigation Pane">
                        <Fluent:DropDownButton.LargeIcon>
                            <Image Source="Resources/NavigationPane.png" />
                        </Fluent:DropDownButton.LargeIcon>
                        <Fluent:MenuItem CanAddToQuickAccessToolBar="False"
                                         Header="Normal"
                                         IsCheckable="True"
                                         IsChecked="{Binding IsMinimized,
                                                             ConverterParameter=Normal,
                                                             Converter={StaticResource BooleanNegateConverter},
                                                             ElementName=navigationPane}" />
                        <Fluent:MenuItem CanAddToQuickAccessToolBar="False"
                                         Header="Minimized"
                                         IsCheckable="True"
                                         IsChecked="{Binding IsMinimized,
                                                             ElementName=navigationPane}" />
                        <Fluent:MenuItem CanAddToQuickAccessToolBar="False"
                                         Header="Off"
                                         IsCheckable="True"
                                         IsChecked="{Binding NavigatioPaneOff,
                                                             ElementName=ribbonWindow}" />
                        <Separator />
                        <Fluent:MenuItem CanAddToQuickAccessToolBar="False"
                                         Command="s:NavigationPane.ConfigureCommand"
                                         CommandParameter="Options"
                                         CommandTarget="{Binding ElementName=navigationPane,
                                                                 Mode=OneWay}"
                                         Header="Options..." />
                    </Fluent:DropDownButton>
                    <Fluent:DropDownButton />
                    <Fluent:DropDownButton Header="Expander">
                        <Fluent:DropDownButton.LargeIcon>
                            <Image Source="/NavigationPaneDemo;component/Resources/Bar.png" />
                        </Fluent:DropDownButton.LargeIcon>
                        <Fluent:MenuItem CanAddToQuickAccessToolBar="False"
                                         Header="Normal"
                                         IsCheckable="True"
                                         IsChecked="{Binding IsMinimized,
                                                             Converter={StaticResource BooleanNegateConverter},
                                                             ElementName=navigationPaneExpander}" />
                        <Fluent:MenuItem CanAddToQuickAccessToolBar="False"
                                         Header="Minimized"
                                         IsCheckable="True"
                                         IsChecked="{Binding IsMinimized,
                                                             ElementName=navigationPaneExpander}" />
                        <Fluent:MenuItem CanAddToQuickAccessToolBar="False"
                                         Header="Off"
                                         IsCheckable="True"
                                         IsChecked="{Binding ExpanderPaneOff,
                                                             ElementName=ribbonWindow}" />
                        <Separator />
                        <Fluent:MenuItem CanAddToQuickAccessToolBar="False"
                                         Command="s:NavigationPane.ConfigureCommand"
                                         CommandParameter="Options"
                                         CommandTarget="{Binding ElementName=Sections}"
                                         Header="Options..." />
                    </Fluent:DropDownButton>
                </Fluent:RibbonGroupBox>
                <Fluent:RibbonGroupBox Header="State">
                    <Fluent:Button Click="Button_Click_1" Header="Save State" />
                    <Fluent:Button Click="Button_Click_2" Header="Load State" />
                </Fluent:RibbonGroupBox>
            </Fluent:RibbonTabItem>
        </Fluent:Ribbon>
        <Fluent:StatusBar VerticalAlignment="Bottom" DockPanel.Dock="Bottom" />

        <s:NavigationPane x:Name="navigationPane"
                          Width="162"
                          Margin="2,0,0,1"
                          BarTitle="lsdajfls"
                          HasResizeThumb="True"
                          SelectedIndex="0"
                          SelectionChanged="navigationPane_SelectionChanged">
            <s:NavigationPane.ItemsButtonsContextMenu>
                <ContextMenu>
                    <s:ConfigureMenuItem MenuType="Options" />
                </ContextMenu>
            </s:NavigationPane.ItemsButtonsContextMenu>
            <s:NavigationPaneItem Name="intro"
                                  Header="Intro"
                                  Image="pack://application:,,,/NavigationPane;Component\Resources\Images\WindowsHS.png">
                <s:NavigationPaneItem.SubItems>
                    <s:NavigationPaneButton Content="prova"
                                            Image="Resources/mail.ico"
                                            ImageSmall="Resources/folderopen.ico" />
                </s:NavigationPaneItem.SubItems>
                <StackPanel>
                    <TextBlock Margin="0,0,0,8"
                               HorizontalAlignment="Left"
                               FontSize="10.667"
                               TextWrapping="Wrap"><Run Language="it-it" Text="This is an Item created directly in the window with xaml." />
                        <LineBreak /><Run Language="it-it" />
                        <LineBreak /><Run Language="it-it" Text="To see an example of an item created in its own xaml file, see the &quot;Theme&quot; item below how it was implemented" />
                        <LineBreak /><Run Language="it-it" />
                        <LineBreak /><Run Language="it-it" Text="Adding items programatically. See window code behind if needed." />
                        <LineBreak /><Run Language="it-it" Text="Hit the Button" />
                    </TextBlock>
                    <TextBlock Margin="8,0,8,2" Text="New item name:" />
                    <TextBox x:Name="newItemName"
                             Margin="8,0,8,4"
                             Text="NewItem" />
                    <TextBlock Margin="8,0,8,2" Text="New item contents:" />
                    <TextBox x:Name="newItemContents"
                             Margin="8,0,8,4"
                             MinLines="4"
                             Text="New Item Contents" />
                    <CheckBox x:Name="newItemExcluded"
                              Margin="8,0,8,4"
                              Content="Create a Disabled Item " />
                    <Button Margin="8,0"
                            Click="Button_Click"
                            Content="Create New Item" />
                </StackPanel>
            </s:NavigationPaneItem>
            <demo:Themes />
        </s:NavigationPane>
        <s:NavigationPaneExpander x:Name="navigationPaneExpander2"
                                  Width="200"
                                  Margin="0,0,2,1"
                                  CloseButtonClick="navigationPaneExpander_CloseButtonClick"
                                  DockPanel.Dock="Right"
                                  FontSize="9.333"
                                  Header="ItemsSource Example"
                                  IsHeaderVisible="True"
                                  ItemsSource="{Binding Collection}"
                                  Orientation="Right" />
        <s:NavigationPaneExpander x:Name="navigationPaneExpander"
                                  Width="200"
                                  Margin="0,0,2,1"
                                  CloseButtonClick="navigationPaneExpander_CloseButtonClick"
                                  DockPanel.Dock="Right"
                                  Orientation="Right">
            <s:NavigationPaneExpander.Header>
                <TextBlock Foreground="Red" Text="Expander Header" />
            </s:NavigationPaneExpander.Header>
            <Grid x:Name="CanResizeContent" s:NavigationPaneExpander.CanResize="False">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Auto">
                    <TextBlock FontSize="10.667"
                               TextAlignment="Right"
                               TextTrimming="WordEllipsis"
                               TextWrapping="Wrap"><Run Text="You can put any control in a " /><Run FontWeight="Bold" Text="NavigationPaneExpander" />
                        <LineBreak /><Run Text="But only " /><Run FontStyle="Italic"
                             FontWeight="Bold"
                             Text="HeaderedItemsControls" /><Run Language="it-it" Text=" " /><Run Text="will show in the bar when minimized." />
                        <LineBreak /><Run Text="Try to minimize me to see the bar." />
                    </TextBlock>
                </ScrollViewer>
                <Separator Grid.Row="1" />
                <TextBlock Grid.Row="2"
                           FontSize="10.667"
                           Text="You can hide the resize thumb by setting the attached property NavigationPaneExpander.CanResize"
                           TextAlignment="Right"
                           TextTrimming="WordEllipsis"
                           TextWrapping="WrapWithOverflow" />
                <s:NavigationPaneButton Grid.Row="3"
                                        Margin="0,2,0,0"
                                        HorizontalContentAlignment="Center"
                                        CheckMode="CheckUncheck"
                                        FontSize="10.667"
                                        FontWeight="Bold"
                                        IsChecked="{Binding (s:NavigationPaneExpander.CanResize),
                                                            ElementName=CanResizeContent,
                                                            Mode=TwoWay}"
                                        Padding="2"
                                        ToolTip="Click me to change the Property CanResize">
                    <!--  Button content is in a TextBlock because buttons in WPf seems to have some problem with StringFormat proerty of Binding  -->
                    <!--
                        In VisualStudio you probably will not see the contents of the button ( vs doesn't supports binding on attached properties !! ) !
                        But at runtime or in Blend will be shown correctly.
                    -->
                    <TextBlock Text="{Binding (s:NavigationPaneExpander.CanResize), ElementName=CanResizeContent, StringFormat=Can Resize: \{0\}}" />
                </s:NavigationPaneButton>
                <Separator Grid.Row="4" />
                <TextBlock Grid.Row="5"
                           FontSize="10.667"
                           FontStyle="Italic"
                           TextAlignment="Right"
                           TextTrimming="WordEllipsis"
                           TextWrapping="WrapWithOverflow"
                           Visibility="{Binding (s:NavigationPaneExpander.CanResize),
                                                Converter={StaticResource BooleanToVisibilityConverter},
                                                ElementName=CanResizeContent}"><Run Text="When visible you can double click the resize thumb to auto size the control." />
                    <LineBreak /><Run Text="You can also use MinHeight and MaxHeight to affect the way the element is resized." />
                </TextBlock>
            </Grid>
            <HeaderedContentControl Name="BarItem1" Header="BarItem1">
                <TextBlock FontSize="10.667"
                           TextAlignment="Right"
                           TextTrimming="WordEllipsis"
                           TextWrapping="Wrap">
                    <Run FontWeight="Bold" Text="BarItem1" />
                    <LineBreak />
                    <Run Text="Being a HeaderedContentControl this one will be shown in the bar." />
                </TextBlock>
            </HeaderedContentControl>
            <HeaderedContentControl>
                <HeaderedContentControl.Header>
                    <StackPanel Orientation="Horizontal">
                        <Image Width="16"
                               Margin="0,0,4,0"
                               VerticalAlignment="Center"
                               Source="Resources/mail.ico" />
                        <TextBlock VerticalAlignment="Center"><Run Text="BarItem2" />
                        </TextBlock>
                    </StackPanel>
                </HeaderedContentControl.Header>
                <TextBlock Name="BarItem2"
                           FontSize="10.667"
                           TextAlignment="Right"
                           TextTrimming="WordEllipsis"
                           TextWrapping="Wrap">
                    <Run FontWeight="Bold" Text="BarItem2" />
                    <LineBreak />
                    <Run Text="This one too will be shown in the bar. But will have an image, since the Header property is not set to a simple string." />
                    <Hyperlink>
                        <Hyperlink.ToolTip>
                            <Fluent:ScreenTip Title="..However.."
                                              Width="200"
                                              Text="Since this is not a NavigationPaneItem, you will notice that image is rotated as the text does. This could be useful if you need to rotate the Header contents. But if you would like to have the image shown properly, you should use a NavigationPaneItem instead of a HeaderedContentControl. Since the control knows how handle NavigationPaneItem image property" />
                        </Hyperlink.ToolTip><Run Text="more..." />
                    </Hyperlink>
                </TextBlock>
            </HeaderedContentControl>
            <s:NavigationPaneItem Name="BarItem3"
                                  Header="BarItem3"
                                  ImageSmall="Resources/mail.ico">
                <TextBlock TextAlignment="Right"
                           TextTrimming="WordEllipsis"
                           TextWrapping="Wrap"><Run Text="This is the native control to put in there !!" />
                </TextBlock>
            </s:NavigationPaneItem>
            <Calendar s:NavigationPaneExpander.CanResize="False" />
        </s:NavigationPaneExpander>

        <Border Margin="2,2,4,4"
                Background="White"
                BorderBrush="{Binding BorderBrush,
                                      ElementName=navigationPane}"
                BorderThickness="1"
                Padding="6">
            <Border.Effect>
                <DropShadowEffect BlurRadius="4"
                                  Opacity="0.3"
                                  ShadowDepth="0"
                                  Color="#AC000000" />
            </Border.Effect>
        </Border>
    </DockPanel>
</Fluent:RibbonWindow>
